package week9.homework;

import week9.homework.StringTooLongException;

import java.util.Scanner;
public class pp11_2 {
    public static void main(String[] args) throws StringTooLongException {
        int an=0;
        Scanner scanner = new Scanner(System.in);
        StringTooLongException problem = new StringTooLongException("Input the length of character string out of range.");
        System.out.println("请输入start");


        while(!scanner.hasNext("DONE")) {

            try {
                System.out.println("请输入不超过20个字母的字符串");
                String a = scanner.nextLine();
                if (a.length() > 20)
                    throw problem;
            } catch (StringTooLongException e) {
                System.out.println("(输入错误)");
            }
        }    System.out.println("The main method end");



    }

}